<html>
<head><meta charset="utf-8"><title>querying type niche status · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html">querying type niche status</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="208738596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208738596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208738596">(Sep 01 2020 at 19:51)</a>:</h4>
<p>Given a type <code>T</code>, is it possible to find out (through any means, stable or not) what kinds of niche optimizations are available for it? I.e. <code>Box&lt;T&gt;</code> is known to be nonzero by the compiler, so it can optimize <code>Option&lt;Box&lt;T&gt;&gt;</code> to have the same size, but <code>Option&lt;Box&lt;T&gt;&gt;</code> does not have the same niche, so <code>Option&lt;Option&lt;Box&lt;T&gt;&gt;&gt;</code> would have to be larger. What even are the possible niche structures that the compiler tracks?</p>



<a name="208748270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208748270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208748270">(Sep 01 2020 at 21:03)</a>:</h4>
<p>You can use <code>#[rustc_layout(abi)]</code> -- <a href="https://doc.rust-lang.org/nightly/unstable-book/language-features/rustc-attrs.html">https://doc.rust-lang.org/nightly/unstable-book/language-features/rustc-attrs.html</a></p>



<a name="208748348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208748348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208748348">(Sep 01 2020 at 21:04)</a>:</h4>
<p>for a type you aren't defining yourself, like <code>Box</code>, just put it in a wrapper</p>



<a name="208748393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208748393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208748393">(Sep 01 2020 at 21:04)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=4ad274185ce1ec73b8cbf6e429140f61">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=4ad274185ce1ec73b8cbf6e429140f61</a></p>
<div class="codehilite"><pre><span></span><code>error: abi: Scalar(Scalar { value: Pointer, valid_range: 1..=18446744073709551615 })
</code></pre></div>



<a name="208748588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208748588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208748588">(Sep 01 2020 at 21:06)</a>:</h4>
<p>whereas <code>Wrapper(Option&lt;Box&lt;i32&gt;&gt;)</code> gives:</p>
<div class="codehilite"><pre><span></span><code>error: abi: Scalar(Scalar { value: Pointer, valid_range: 1..=0 })
</code></pre></div>



<a name="208748631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208748631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208748631">(Sep 01 2020 at 21:06)</a>:</h4>
<p>the range wraps, for whatever reason</p>



<a name="208749154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208749154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208749154">(Sep 01 2020 at 21:10)</a>:</h4>
<p>oh wow, that's really nice</p>



<a name="208749217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208749217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208749217">(Sep 01 2020 at 21:10)</a>:</h4>
<p><code>#[rustc_layout(debug)]</code> is probably more what you want, with the <code>largest_niche</code> field</p>



<a name="208749261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208749261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208749261">(Sep 01 2020 at 21:11)</a>:</h4>
<p>I will make sure to abuse this in my <code>unsafe</code> code ;P</p>



<a name="208751121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208751121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208751121">(Sep 01 2020 at 21:26)</a>:</h4>
<p>note that, in general, these details are not stable</p>



<a name="208751132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208751132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208751132">(Sep 01 2020 at 21:26)</a>:</h4>
<p>some specific optimizations are guaranteed by the language though</p>



<a name="208800927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208800927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208800927">(Sep 02 2020 at 09:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/208749261">said</a>:</p>
<blockquote>
<p>I will make sure to abuse this in my <code>unsafe</code> code ;P</p>
</blockquote>
<p>definitely please do not do that. consult <a href="https://rust-lang.github.io/unsafe-code-guidelines/">the docs</a> for what niches are actually guaranteed, and be mindful of the notes in those docs for things that are not RFC'd yet -- they cannot be relied upon either.</p>



<a name="208804720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208804720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208804720">(Sep 02 2020 at 10:35)</a>:</h4>
<p>I am of course aware of the instability of <code>repr(Rust)</code>, although it would be great if I could static assert that a repr rust type has a particular abi so that I can at least know when it's going to work. The usual time I find myself doing these dirty hacks is when I want to expose some private state in another crate, because I need to make a small tweak to the library and don't want to copy paste and fork the whole crate.</p>



<a name="208805014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208805014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208805014">(Sep 02 2020 at 10:38)</a>:</h4>
<p>Actually the example that prompted this question was just when I wanted to double check that <code>Option&lt;Arc&lt;T&gt;&gt;</code> is no bigger than <code>Arc&lt;T&gt;</code> for my own understanding, no unsafe needed</p>



<a name="208805481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208805481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208805481">(Sep 02 2020 at 10:43)</a>:</h4>
<p>I guess I would say that the wobbly <code>repr(Rust)</code> ABI goes against the idea of systems programming giving the programmer control of the hardware (rather than the language/compiler keeping that control for itself). I know why it is the way it is but that doesn't mean I have to like it.</p>



<a name="208849927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208849927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208849927">(Sep 02 2020 at 16:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/208805481">said</a>:</p>
<blockquote>
<p>I guess I would say that the wobbly <code>repr(Rust)</code> ABI goes against the idea of systems programming giving the programmer control of the hardware (rather than the language/compiler keeping that control for itself). I know why it is the way it is but that doesn't mean I have to like it.</p>
</blockquote>
<p>That's a bit like saying that compiler optimizations go against "the idea of system programming" because the programmer cannot control what exactly the assembly is that is being produced.</p>



<a name="208850009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208850009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208850009">(Sep 02 2020 at 16:19)</a>:</h4>
<p>If you want <em>full</em> control, use assembly. If you want a higher-level language than that, there's an inherent trade-off between giving guarnatees and being able to make code go faster. Rust offers both options, that's why we have <code>repr(Rust)</code> and <code>repr(C)</code>.</p>



<a name="208850067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208850067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208850067">(Sep 02 2020 at 16:19)</a>:</h4>
<p>If you decide against using <code>repr(C)</code>, you get the benefits and the cost of "wobbly" <code>repr(Rust)</code>. It's your choice, but there's no way to provide the benefits without the costs. You can have all the control you want, you just have to ask the compiler (and possibly library author, if it's not your type) for it.</p>



<a name="208896090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896090">(Sep 02 2020 at 22:24)</a>:</h4>
<blockquote>
<p>That's a bit like saying that compiler optimizations go against "the idea of system programming" because the programmer cannot control what exactly the assembly is that is being produced.</p>
</blockquote>
<p>Well, they do. The point is that in a good systems language I can tell the compiler, in a targeted way, "don't touch my code <em>here</em>". That includes things like the <code>volatile</code> keyword and inline assembly. I think it is a false dichotomy to say that I should go write in assembly if I want that kind of control, because C is a classic example of bridging that gap.</p>
<blockquote>
<p>If you decide against using repr(C), you get the benefits and the cost of "wobbly" repr(Rust). It's your choice, but there's no way to provide the benefits without the costs. You can have all the control you want, you just have to ask the compiler (and possibly library author, if it's not your type) for it.</p>
</blockquote>
<p>I definitely see ways that we could have our cake and eat it too in this department. I can already write target specific code using <code>#[cfg(windows)]</code> and <code>#[cfg(x86)]</code> and the like, but I can't write code that is tailored to the compiler's possible layout options. The standardization process around repr(Rust) has been going nowhere for years and so I'm forced to write to the compiler as it exists rather than the spec I would like to have (which is very common in C circles but something I try to avoid in Rust because the standardization process has been better in most areas).</p>
<p>C++ standards guys can say "but that's UB" until they are blue in the face but that won't stop people from exploiting compiler behavior because the standard isn't meeting their needs. Until the next compiler version comes out, people's code breaks, and everyone is disappointed.</p>



<a name="208896553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896553">(Sep 02 2020 at 22:29)</a>:</h4>
<p>It's not at all clear why you're saying <code>#[repr(C)]</code> doesn't work for you. That's the mechanism to say "lay this out in a specific standard way".</p>



<a name="208896609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896609">(Sep 02 2020 at 22:30)</a>:</h4>
<p>When you say "The standardization process around repr(Rust) has been going nowhere for years", that implies there's a standardization process, as opposed to a deliberate decision to not stabilize that repr's layout.</p>



<a name="208896629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896629">(Sep 02 2020 at 22:30)</a>:</h4>
<p>The usual place this comes up is when I want to work with someone else's library without changing their code</p>



<a name="208896702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896702">(Sep 02 2020 at 22:30)</a>:</h4>
<p>I can pin down their library by not upgrading or doing it consciously but I lack the tools to pin down the compiler</p>



<a name="208896768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896768">(Sep 02 2020 at 22:31)</a>:</h4>
<p>What kinds of things would you like to do that depend on structure layout?</p>



<a name="208896811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896811">(Sep 02 2020 at 22:31)</a>:</h4>
<p>getting access to private fields is a classic example</p>



<a name="208896900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896900">(Sep 02 2020 at 22:32)</a>:</h4>
<p>That's not making a good case for why the compiler should <em>want</em> to enable this. ;)</p>



<a name="208896910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896910">(Sep 02 2020 at 22:32)</a>:</h4>
<p>yeah it's a horrible hack, but that doesn't mean rust should be actively trying to break my code</p>



<a name="208896926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896926">(Sep 02 2020 at 22:32)</a>:</h4>
<p>But also, that <em>is</em> something that you can do without relying on the layout of repr(Rust).</p>



<a name="208896936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896936">(Sep 02 2020 at 22:32)</a>:</h4>
<p>Declare another structure with exactly the same fields, and transmute.</p>



<a name="208896961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896961">(Sep 02 2020 at 22:33)</a>:</h4>
<p>Then you're not counting on the layout, only counting on Rust to lay out two identical structures identically, which is not as much of an assumption.</p>



<a name="208896972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208896972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208896972">(Sep 02 2020 at 22:33)</a>:</h4>
<p>That's one of many reasonable things that is being deliberately not committed to</p>



<a name="208897086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897086">(Sep 02 2020 at 22:34)</a>:</h4>
<p>True. The moment there's a useful optimization that would depend on breaking that assumption, where on the one side of the balance we have "optimize Rust code for everyone" and on the other side we have "break hacks used to access private fields from a third-party crate", it's not hard to imagine which way that goes.</p>



<a name="208897110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897110">(Sep 02 2020 at 22:34)</a>:</h4>
<p>reading <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/11">https://github.com/rust-lang/unsafe-code-guidelines/issues/11</a> has been an exercise in frustration</p>



<a name="208897137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897137">(Sep 02 2020 at 22:35)</a>:</h4>
<p>You might be better off forking the third-party crate, adding the changes you want, and using the fork.</p>



<a name="208897228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897228">(Sep 02 2020 at 22:36)</a>:</h4>
<p>The thing is, I'm okay writing crazy macro stuff if it means I can make my hack work reliably, but rust doesn't seem to want to work with that</p>



<a name="208897296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897296">(Sep 02 2020 at 22:37)</a>:</h4>
<p>Like I said, I'm not opposed to letting rust retain flexibility in data layout, but it should expose some of what it's doing to unsafe code that is forced to rely on it to make <code>transmute</code> stuff work</p>



<a name="208897393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897393">(Sep 02 2020 at 22:38)</a>:</h4>
<p>I think that immediately backing off with "you are on your own because you wrote <code>unsafe</code>" is the wrong approach here</p>



<a name="208897406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897406">(Sep 02 2020 at 22:38)</a>:</h4>
<p>/me is re-reading that issue now.</p>



<a name="208897617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897617">(Sep 02 2020 at 22:40)</a>:</h4>
<p>It occurs to me that safe-transmute would make it possible for the compiler to confirm for you at the type level that two types have the same layout.</p>



<a name="208897646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897646">(Sep 02 2020 at 22:41)</a>:</h4>
<p>And safe-transmute has the concept of "stability", which is something that <em>can</em> be bypassed to get at private fields.</p>



<a name="208897657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897657">(Sep 02 2020 at 22:41)</a>:</h4>
<p>So that might be the path to what you want.</p>



<a name="208897680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897680">(Sep 02 2020 at 22:41)</a>:</h4>
<p>(That said, I still think any structure for which you care about layout should use <code>repr(C)</code>.)</p>



<a name="208897764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897764">(Sep 02 2020 at 22:42)</a>:</h4>
<p>I think the limiting case of what I'm talking about is something like compile time reflection of data layouts, i.e. functions like <code>size_of</code> but for ABI details</p>



<a name="208897851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897851">(Sep 02 2020 at 22:43)</a>:</h4>
<p>So, for instance, <code>offset_of</code>?</p>



<a name="208897913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897913">(Sep 02 2020 at 22:43)</a>:</h4>
<p>that would be great</p>



<a name="208897972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208897972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208897972">(Sep 02 2020 at 22:44)</a>:</h4>
<p>that's good enough for extracting private fields, not quite good enough for safe transmute of complex types</p>



<a name="208898035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898035">(Sep 02 2020 at 22:45)</a>:</h4>
<p>A trait based approach to safe transmute is likely to not be powerful enough in general</p>



<a name="208898086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898086">(Sep 02 2020 at 22:45)</a>:</h4>
<p>I can imagine some turing complete stuff sneaking in here, so a const fn approach seems a bit more general</p>



<a name="208898102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898102">(Sep 02 2020 at 22:46)</a>:</h4>
<p>Clarification: <code>offset_of</code> likely won't be enough to access private fields, because you (hopefully) wouldn't be able to use it on a field you couldn't access.</p>



<a name="208898160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898160">(Sep 02 2020 at 22:46)</a>:</h4>
<p>I figured</p>



<a name="208898191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898191">(Sep 02 2020 at 22:46)</a>:</h4>
<p>I'd be curious to have an example of a third-party crate for which you have a reason to access a private field, and for which fixing the crate isn't an option.</p>



<a name="208898230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898230">(Sep 02 2020 at 22:47)</a>:</h4>
<p>These things usually work themselves out eventually, so the dirty hacks don't make it into production, but sometimes I'm too impatient for my PR to land :)</p>



<a name="208898249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898249">(Sep 02 2020 at 22:47)</a>:</h4>
<p>and if not I can always fork</p>



<a name="208898298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898298">(Sep 02 2020 at 22:48)</a>:</h4>
<p>/me has, many times, cloned a crate locally, and used a <code>path</code> dependency to test it.</p>



<a name="208898338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898338">(Sep 02 2020 at 22:48)</a>:</h4>
<p>But in any case, I think for that kind of hack it'd be "reasonable" to just count on the compiler to not reorder, and watch the release notes to see if that's going to change. ;)</p>



<a name="208898581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898581">(Sep 02 2020 at 22:51)</a>:</h4>
<p>I agree. Which is why I find the stubborn lack of any guarantees for repr(Rust) structs so frustrating. (Aside: one person mentioned that they thought that it would be surprising that reordering the fields of a struct with named fields would break the ABI, citing things like alphabetizing field names. Is this sentiment common? I find the opposite surprising.)</p>



<a name="208898643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898643">(Sep 02 2020 at 22:52)</a>:</h4>
<p>I think it's reasonable to treat the order of <em>pub</em> fields in a pub <code>repr(C)</code> struct as part of the ABI.</p>



<a name="208898682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898682">(Sep 02 2020 at 22:53)</a>:</h4>
<p>But also, I think it's counterproductive to call someone not doing what you want "stubborn". There are reasons, whether you like those reasons or not.</p>



<a name="208898758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898758">(Sep 02 2020 at 22:54)</a>:</h4>
<p>The compiler provides <code>repr(C)</code> for a reason.</p>



<a name="208898784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208898784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208898784">(Sep 02 2020 at 22:54)</a>:</h4>
<p>I'd also say that once we have <code>offset_of</code>, it'd be reasonable to use it on public fields and rely on it, but not reasonable (for instance) to expect field offsets not to change.</p>



<a name="208899041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899041">(Sep 02 2020 at 22:58)</a>:</h4>
<p>I think it is not okay to make the rust compiler adversarial, using fuzzing and things to attempt to break my code while also not providing the means to play along and choose an appropriate course of action based on layout decisions. That's not a fair fight</p>



<a name="208899157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899157">(Sep 02 2020 at 22:59)</a>:</h4>
<p>Nobody is making it adversarial.</p>



<a name="208899239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899239">(Sep 02 2020 at 23:00)</a>:</h4>
<p>The randomization stuff is pretty adversarial</p>



<a name="208899276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899276">(Sep 02 2020 at 23:00)</a>:</h4>
<p>I did see the discussions about randomized layout in the issue you linked, but I don't believe those were about being adversarial towards the <em>developer</em>. That's about being adversarial towards <em>bugs</em> or <em>attacks</em>.</p>



<a name="208899303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899303">(Sep 02 2020 at 23:00)</a>:</h4>
<p>(Also, I'd personally oppose having randomized structure layout by default, though I'd support having an option for it.)</p>



<a name="208899329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899329">(Sep 02 2020 at 23:01)</a>:</h4>
<p>I realize that, but it's inadvertently ending up adversarial to the developer in this instance</p>



<a name="208899426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899426">(Sep 02 2020 at 23:02)</a>:</h4>
<p>In general, I tend to be one of the strongest advocates for "let's not break existing code, even if that code is using undefined behavior, and <em>especially</em> without a transition plan and an alternative to offer".</p>



<a name="208899472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899472">(Sep 02 2020 at 23:02)</a>:</h4>
<p>I would like to be able to write <em>correct</em> unsafe hackery</p>



<a name="208899503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899503">(Sep 02 2020 at 23:02)</a>:</h4>
<p>rust gives me correct and it gives me unsafe but apparently not at the same time</p>



<a name="208899518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899518">(Sep 02 2020 at 23:03)</a>:</h4>
<p>I think you're rather unfairly maligning the compiler's intentions here.</p>



<a name="208899529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899529">(Sep 02 2020 at 23:03)</a>:</h4>
<p>Rust gives you plenty of ways to write correct unsafe code.</p>



<a name="208899590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899590">(Sep 02 2020 at 23:04)</a>:</h4>
<p>Such as <code>repr(C)</code> for instance.</p>



<a name="208899638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899638">(Sep 02 2020 at 23:04)</a>:</h4>
<p>What if I <em>want</em> Rust to lay out my struct</p>



<a name="208899675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899675">(Sep 02 2020 at 23:05)</a>:</h4>
<p>Your use case of "I want to access the private fields of a third-party type that doesn't use <code>repr(C)</code>, and rely on its layout to do so" is firmly in the realm where I'd argue that we shouldn't <em>gratuitously</em> break that, but we shouldn't commit to it working at the expense of future optimizations either.</p>



<a name="208899815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899815">(Sep 02 2020 at 23:06)</a>:</h4>
<p>If you want Rust to lay out your struct in a specific well-defined way, you should tell Rust to do that. Rust has a way to do exactly that.</p>



<a name="208899818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899818">(Sep 02 2020 at 23:06)</a>:</h4>
<p>I know that rust wants layout freedom and I'm on board with that, but I don't think <code>repr(C)</code> is the answer because most types are not <code>repr(C)</code></p>



<a name="208899876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208899876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208899876">(Sep 02 2020 at 23:07)</a>:</h4>
<p>nor should they be, Rust is good at using tricks to do good layouts and I have no desire to get in the way of that</p>



<a name="208900021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900021">(Sep 02 2020 at 23:09)</a>:</h4>
<p>but I think it should be possible for the programmer to write code that depends on data layout in a more complex way than simple field access</p>



<a name="208900071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900071">(Sep 02 2020 at 23:09)</a>:</h4>
<p>I agree that it should be possible. I think that <code>offset_of</code> for public fields makes sense, and I think that it should be possible to <em>tell</em> the compiler to lay out a structure in a precise way.</p>



<a name="208900078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900078">(Sep 02 2020 at 23:09)</a>:</h4>
<p>I think safe transmute is just one instance of this, my private field extraction is another example</p>



<a name="208900131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900131">(Sep 02 2020 at 23:10)</a>:</h4>
<p>I also think it'd be possible to support the use case you're looking for via safe-transmute.</p>



<a name="208900331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900331">(Sep 02 2020 at 23:12)</a>:</h4>
<p>By the way, is there a particular preferred safe-transmute proposal right now? I feel like I've read several, none with clear support</p>



<a name="208900333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900333">(Sep 02 2020 at 23:12)</a>:</h4>
<p>Going back to a much earlier point: I <em>do</em> think the compiler should have ways of allowing you to specify "do exactly what I say here". <code>repr(C)</code> is one such mechanism. And when you <em>don't</em> use those mechanisms, I think it's reasonable for the compiler to have more flexibility.</p>



<a name="208900351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900351">(Sep 02 2020 at 23:12)</a>:</h4>
<p>Yes, there is: <a href="https://github.com/rust-lang/rfcs/pull/2981">https://github.com/rust-lang/rfcs/pull/2981</a></p>



<a name="208900379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900379">(Sep 02 2020 at 23:13)</a>:</h4>
<p>(Just a note in advance: going there and trying to advocate for the use case of accessing private fields is probably not going to go over well.)</p>



<a name="208900403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900403">(Sep 02 2020 at 23:13)</a>:</h4>
<p>;)</p>



<a name="208900418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900418">(Sep 02 2020 at 23:13)</a>:</h4>
<p>I just want Rust to be a better C</p>



<a name="208900616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900616">(Sep 02 2020 at 23:15)</a>:</h4>
<p>So do many of us, myself included, but I think that there are many different ideas on what "a better C" means.</p>



<a name="208900648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900648">(Sep 02 2020 at 23:15)</a>:</h4>
<p>I don't want Rust to be "a better portable assembler" by default, though it should have some options to help with such use cases. ;)</p>



<a name="208900841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900841">(Sep 02 2020 at 23:17)</a>:</h4>
<p>As one random example of something I'd like to have that involves structure layout: I'd love to be able to have the compiler detect that of all the code being compiled, absolutely nothing ever reads a field, and nothing ever transmutes the structure from something else, so the field effectively doesn't exist and all writes to it could be ignored.</p>



<a name="208900937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900937">(Sep 02 2020 at 23:19)</a>:</h4>
<p>That's another thing that having an explicit layout API would help with</p>



<a name="208900978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208900978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208900978">(Sep 02 2020 at 23:19)</a>:</h4>
<p>since the compiler can see that you called <code>size_of::&lt;T&gt;()</code> instead of just <code>24</code></p>



<a name="208901011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901011">(Sep 02 2020 at 23:20)</a>:</h4>
<p>actually, it occurs to me that a much simpler way to achieve what I'm talking about is to just be able to override privacy annotations</p>



<a name="208901103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901103">(Sep 02 2020 at 23:20)</a>:</h4>
<p>Though that would be inherently unstable, and unsafe, I don't necessarily see a reason <em>not</em> to allow it.</p>



<a name="208901116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901116">(Sep 02 2020 at 23:21)</a>:</h4>
<p>Of course I know that won't go over well, and obviously such uses should come with lots of explicit warning flags because it's not a recommended thing, but it solves a lot of problems</p>



<a name="208901126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901126">(Sep 02 2020 at 23:21)</a>:</h4>
<p>it is your program's data, after all</p>



<a name="208901288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901288">(Sep 02 2020 at 23:23)</a>:</h4>
<p>I would personally be unsure about how we'd communicate the lack of stability there -- seems dangerous to Rust's stability as a whole</p>



<a name="208901304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901304">(Sep 02 2020 at 23:23)</a>:</h4>
<p>how so?</p>



<a name="208901357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901357">(Sep 02 2020 at 23:24)</a>:</h4>
<p>I think of it like a crate "friend"</p>



<a name="208901390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901390">(Sep 02 2020 at 23:24)</a>:</h4>
<p>you gain access to the internals of the crate in return for having to upgrade as a unit</p>



<a name="208901398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901398">(Sep 02 2020 at 23:25)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> I wouldn't object as long as both sides had to declare it.</p>



<a name="208901403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901403">(Sep 02 2020 at 23:25)</a>:</h4>
<p>right, I'm saying that you need that "unit upgrade" piece</p>



<a name="208901419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901419">(Sep 02 2020 at 23:25)</a>:</h4>
<p>which we don't currently have, but there's a bunch of reasons to want "friend crates" that don't involve this</p>



<a name="208901451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901451">(Sep 02 2020 at 23:25)</a>:</h4>
<p>(The reason I'd want both sides to declare it is that it would allow violating the safety assumptions of a crate, not just stability.)</p>



<a name="208901460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901460">(Sep 02 2020 at 23:25)</a>:</h4>
<p>(For instance, a field might be private to maintain an invariant.)</p>



<a name="208901464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901464">(Sep 02 2020 at 23:25)</a>:</h4>
<p>Well if crate A upgrades and B is a friend of A then it doesn't have to upgrade if it doesn't touch its toml file</p>



<a name="208901536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901536">(Sep 02 2020 at 23:26)</a>:</h4>
<p>(you might have to specify a particular version in B's toml file)</p>



<a name="208901563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901563">(Sep 02 2020 at 23:26)</a>:</h4>
<p>You mean <code>=</code> dependencies rather than normal <code>^</code> semver-compat deps?</p>



<a name="208901570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901570">(Sep 02 2020 at 23:26)</a>:</h4>
<p>yes</p>



<a name="208901606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901606">(Sep 02 2020 at 23:27)</a>:</h4>
<p>rustc can't know if you're using <code>=</code> dependencies today though, and that would be "hard"</p>



<a name="208901608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901608">(Sep 02 2020 at 23:27)</a>:</h4>
<p>because semver-compat deps can break or change internal invariants</p>



<a name="208901623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901623">(Sep 02 2020 at 23:27)</a>:</h4>
<p>I don't follow</p>



<a name="208901644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901644">(Sep 02 2020 at 23:27)</a>:</h4>
<p>rustc has no idea what version crates are, that's a cargo concern</p>



<a name="208901705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901705">(Sep 02 2020 at 23:28)</a>:</h4>
<p>right, but rustc also doesn't deal with upgrades</p>



<a name="208901711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901711">(Sep 02 2020 at 23:28)</a>:</h4>
<p>and presumably we'd want rustc to forbid reading details of a foreign crate without it being declared as a = dep</p>



<a name="208901719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901719">(Sep 02 2020 at 23:28)</a>:</h4>
<p>(e.g., you'd never be able to do this for std)</p>



<a name="208901752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901752">(Sep 02 2020 at 23:28)</a>:</h4>
<p>because I think if you were able, then we'd likely end up in a world where std's structs are de-facto stable and that seems really bad</p>



<a name="208901761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901761">(Sep 02 2020 at 23:28)</a>:</h4>
<p>no, I think rustc should only require that you say <code>unsafe friend_of extern crate std;</code> or something</p>



<a name="208901789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901789">(Sep 02 2020 at 23:29)</a>:</h4>
<p>and if you do, then you must also tie yourself to a particular version in the cargo file</p>



<a name="208901795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901795">(Sep 02 2020 at 23:29)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> And then you upgrade rustc, which changes the layout of std's internal data structures, and your code breaks.</p>



<a name="208901810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901810">(Sep 02 2020 at 23:29)</a>:</h4>
<p>Cargo has no way right now to express a versioned dependency on std.</p>



<a name="208901820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901820">(Sep 02 2020 at 23:29)</a>:</h4>
<p>And also, the declaration you suggested gives no indication of version.</p>



<a name="208901899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901899">(Sep 02 2020 at 23:30)</a>:</h4>
<p>the version would go in the cargo file</p>



<a name="208901905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901905">(Sep 02 2020 at 23:30)</a>:</h4>
<p>rustc doesn't read that cargo file</p>



<a name="208901930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901930">(Sep 02 2020 at 23:30)</a>:</h4>
<p>how does rustc get the std lib?</p>



<a name="208901960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901960">(Sep 02 2020 at 23:31)</a>:</h4>
<p>loads from sysroot</p>



<a name="208901962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901962">(Sep 02 2020 at 23:31)</a>:</h4>
<p>do the library files come bundled with the compiler?</p>



<a name="208901969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901969">(Sep 02 2020 at 23:31)</a>:</h4>
<p>today, yes</p>



<a name="208901975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901975">(Sep 02 2020 at 23:31)</a>:</h4>
<p>(though they don't have to)</p>



<a name="208901986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208901986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208901986">(Sep 02 2020 at 23:31)</a>:</h4>
<p>so a given version of rustc sees a given version of std</p>



<a name="208902027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902027">(Sep 02 2020 at 23:32)</a>:</h4>
<p>and they always upgrade together</p>



<a name="208902078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902078">(Sep 02 2020 at 23:32)</a>:</h4>
<p>And where does the declaration of what version of std you're relying on the internal data structures of go?</p>



<a name="208902095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902095">(Sep 02 2020 at 23:32)</a>:</h4>
<p>in which case if you friend std then you are stuck with a particular version of rustc, or more likely you are friends with the dev team or watching changes</p>



<a name="208902099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902099">(Sep 02 2020 at 23:32)</a>:</h4>
<p>I think any solution needs to address somehow the problem that if we permit reaching into std internals, it becomes a conversation of "well how much code will we break in practice" every time we change those.</p>



<a name="208902123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902123">(Sep 02 2020 at 23:33)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> If we even <em>considered</em> this, which I don't think we should, it should go hand in hand with saying we <em>don't</em> have to consider that.</p>



<a name="208902135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902135">(Sep 02 2020 at 23:33)</a>:</h4>
<p>By doing this you definitely opt out of any stability guarantees with that crate</p>



<a name="208902163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902163">(Sep 02 2020 at 23:33)</a>:</h4>
<p>Sure, but my point is that we <em>have</em> said that e.g. for type inference or breaking itertools due to "adding a method to Iterator" or "TryFrom/Into" and all of those... have caused us to back away</p>



<a name="208902214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902214">(Sep 02 2020 at 23:34)</a>:</h4>
<p>That's more a political problem</p>



<a name="208902238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902238">(Sep 02 2020 at 23:34)</a>:</h4>
<p>Welcome to Rust, we care about social problems and community. ;)</p>



<a name="208902239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902239">(Sep 02 2020 at 23:34)</a>:</h4>
<p>It is still a problem that must be addressed, perhaps even more so because of that.</p>



<a name="208902270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902270">(Sep 02 2020 at 23:35)</a>:</h4>
<p>if my awesome crate that is a friend of yours becomes big and important, then you may well make decisions based on how my crate responds, but that seems like a second order effect</p>



<a name="208902372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902372">(Sep 02 2020 at 23:36)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> Your phrasing seems like it's describing the fundamental problem. Friendship is not unilateral.</p>



<a name="208902397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902397">(Sep 02 2020 at 23:36)</a>:</h4>
<p>This is like being friends with a youtube celeb :)</p>



<a name="208902416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902416">(Sep 02 2020 at 23:36)</a>:</h4>
<p>Yes, and they don't let you get at their private details either. ;)</p>



<a name="208902418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902418">(Sep 02 2020 at 23:36)</a>:</h4>
<p>My problem is that if the friend relationship is not mutual then you end up in a pretty unfortunate world of everyone needing to think "well who am I going to break in practice" and I think that's unfortunate and, personally, might be a dealbreaker for stabilization at least.</p>



<a name="208902450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902450">(Sep 02 2020 at 23:37)</a>:</h4>
<p>Though perhaps not for forever-nightly.</p>



<a name="208902476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902476">(Sep 02 2020 at 23:37)</a>:</h4>
<p>That's probably fair</p>



<a name="208902478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902478">(Sep 02 2020 at 23:37)</a>:</h4>
<p>That said, I think friend crates are <em>very</em> much desired for a number of reasons that are somewhat orthogonal to this</p>



<a name="208902530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902530">(Sep 02 2020 at 23:38)</a>:</h4>
<p>e.g., being able to <code>impl ForeignType { .. }</code> for a friend crate</p>



<a name="208902553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902553">(Sep 02 2020 at 23:38)</a>:</h4>
<p>I don't have a good understanding of the roles that stable/beta/nightly play but this does seem like a good candidate for never-stable</p>



<a name="208902582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902582">(Sep 02 2020 at 23:38)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> Now <em>that</em> is something I'd really like to have, if we can deal with coherence issues.</p>



<a name="208902605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902605">(Sep 02 2020 at 23:39)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> If you don't mind using nightly, what about a <code>-Z struct-layout-xyz</code> option to specify struct layout?</p>



<a name="208902625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902625">(Sep 02 2020 at 23:39)</a>:</h4>
<p>Right, yes, the "friend crate" is the enabler for bypassing coherence, basically placing a set of crates into a single coherence context, IMO.</p>



<a name="208902632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902632">(Sep 02 2020 at 23:39)</a>:</h4>
<p>Though I'm sure there's a ton of details to work out.</p>



<a name="208902636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902636">(Sep 02 2020 at 23:39)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> e.g. <code>-Z struct-layout-Rust-like-C</code>.</p>



<a name="208902667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902667">(Sep 02 2020 at 23:39)</a>:</h4>
<p>If you're fine with it being unstable, then you can already query type layout with -Zprint-type-sizes or <code>#[rustc_layout(debug)]</code> and then manually access it</p>



<a name="208902732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902732">(Sep 02 2020 at 23:40)</a>:</h4>
<p>obviously it's, well, "keep your compiler and deps pinned"</p>



<a name="208902741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902741">(Sep 02 2020 at 23:40)</a>:</h4>
<p>Well I can always just <code>*(p+8)</code> too</p>



<a name="208902773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902773">(Sep 02 2020 at 23:40)</a>:</h4>
<p>I personally would agree with <span class="user-mention" data-user-id="239881">@Josh Triplett</span> that we're highly unlikely to ever randomly re-order structs on you without opt-in</p>



<a name="208902795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902795">(Sep 02 2020 at 23:41)</a>:</h4>
<p>I'm just hoping to ultimately find something more correct than that</p>



<a name="208902851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902851">(Sep 02 2020 at 23:41)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> To try and understand -- what would you expect instead of that? Something like <code>bypass_privacy!(p.foo)</code>?</p>



<a name="208902914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902914">(Sep 02 2020 at 23:42)</a>:</h4>
<p>I think it's going to be a pretty hard sell given the "easy edit" nature of most Rust dependencies</p>



<a name="208902973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208902973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208902973">(Sep 02 2020 at 23:42)</a>:</h4>
<p>I was thinking the privacy bypass would be at the top level, like <code>bypass_privacy! use other_crate::foo;</code></p>



<a name="208903011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208903011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208903011">(Sep 02 2020 at 23:43)</a>:</h4>
<p>at which point it becomes "as if" you were writing code inside that module</p>



<a name="208903035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208903035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208903035">(Sep 02 2020 at 23:43)</a>:</h4>
<p>also gotta throw an <code>unsafe</code> in there to appease the masses</p>



<a name="208903126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208903126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Monadic Cat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208903126">(Sep 02 2020 at 23:44)</a>:</h4>
<p><code>#![unsafe_invade(other_crate::foo)]</code></p>



<a name="208903150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208903150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208903150">(Sep 02 2020 at 23:45)</a>:</h4>
<p>That feels worse than a local bypass, personally, and I'm not sure what benefit a global one brings.</p>



<a name="208903193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208903193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Monadic Cat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208903193">(Sep 02 2020 at 23:45)</a>:</h4>
<p>Maybe require it noted at the top level, and still require access via a macro locally?</p>



<a name="208903196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208903196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208903196">(Sep 02 2020 at 23:45)</a>:</h4>
<p>I don't think that crate boundaries can be meaningfully bypassed "just a little"</p>



<a name="208903275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208903275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208903275">(Sep 02 2020 at 23:46)</a>:</h4>
<p>Well, the local bypass means that you can easily find where you're doing it which seems like a win. Spooky action at a distance feels bad.</p>



<a name="208903290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208903290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Monadic Cat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208903290">(Sep 02 2020 at 23:46)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="cp">#![feature(privacy_invasion)]</span><span class="w"></span>
<span class="cp">#![unsafe_invade(other_crate::foo)]</span><span class="w"></span>

<span class="c1">// Later...</span>

<span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">invade</span><span class="o">!</span><span class="p">(</span><span class="n">foo</span><span class="p">.</span><span class="n">b</span><span class="p">);</span><span class="w"> </span><span class="c1">// Accessing a private field.</span>
</code></pre></div>



<a name="208903297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208903297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208903297">(Sep 02 2020 at 23:46)</a>:</h4>
<p>Maybe it's something like unsafe_op_in_unsafe_fn</p>



<a name="208903463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208903463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208903463">(Sep 02 2020 at 23:48)</a>:</h4>
<p>That could get tiresome if you are writing a whole function in that style though</p>



<a name="208903492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208903492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208903492">(Sep 02 2020 at 23:49)</a>:</h4>
<p>it seems very similar to <code>unsafe</code> blocks</p>



<a name="208904126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208904126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208904126">(Sep 02 2020 at 23:56)</a>:</h4>
<p>Ah, here's a more plausible use case: you discover there is a fatal flaw in <code>Mutex::lock</code> that is causing your web server to be susceptible to the latest 0-day, and you can't wait for the patch to land in the next version. This would let you patch just that function, writing from within the context that the original was written. (You might be able to copy the whole type, but depending on how intrinsically linked it is to other private stuff that might involve cloning the whole library, and might require a larger change to the build setup.)</p>



<a name="208907176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208907176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208907176">(Sep 03 2020 at 00:37)</a>:</h4>
<p>If you need fixes quicker than the ~1 day theoretical minimum turn around that we could in theory provide with a Rust release, then it seems reasonable to expect that you will pay someone to support you, similar to RHEL - who you can expect to patch and issue updates to libraries like std faster.</p>
<p>Maybe that's not a satisfying answer, but it feels like the right one - ultimately it's not that hard to replace std if you're in a situation where you must patch 0 days rapidly and via std replacement (and not e.g. request filtering or something).</p>



<a name="208910810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208910810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208910810">(Sep 03 2020 at 01:42)</a>:</h4>
<p>Also, I'd like to have <code>-Zbuild-std </code>working well enough that it's <em>theoretically</em> possible to build with a patched version of std with about the same difficulty as building with a patched version of any of your direct or indirect dependencies.</p>



<a name="208910815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208910815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208910815">(Sep 03 2020 at 01:42)</a>:</h4>
<p>(e.g. cargo's functionality to replace a crate)</p>



<a name="208910829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208910829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208910829">(Sep 03 2020 at 01:43)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> has said a few times they would love to be able to <code>cargo test</code> for the standard library itself</p>



<a name="208910837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208910837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208910837">(Sep 03 2020 at 01:43)</a>:</h4>
<p>i.e. not going through bootstrap</p>



<a name="208910947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208910947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208910947">(Sep 03 2020 at 01:45)</a>:</h4>
<p>I guess my mental model of the stdlib is incorrect. I thought that std was just a library (used to help build rustc)?</p>



<a name="208911004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911004">(Sep 03 2020 at 01:46)</a>:</h4>
<p>std and rustc are developed with each other</p>



<a name="208911059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911059">(Sep 03 2020 at 01:46)</a>:</h4>
<p>it's sort of the same model as C, where 'the implementation' includes both the standard library and the compiler</p>



<a name="208911067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911067">(Sep 03 2020 at 01:47)</a>:</h4>
<p>sure, but in the final stage you have a working rustc which builds the std sources + your crate</p>



<a name="208911081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911081">(Sep 03 2020 at 01:47)</a>:</h4>
<p>so e.g. libstd depends on implementation details of rustc that aren't stable</p>



<a name="208911146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911146">(Sep 03 2020 at 01:48)</a>:</h4>
<p>right, it is a "friend" of rustc in the present terminology</p>



<a name="208911161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911161">(Sep 03 2020 at 01:48)</a>:</h4>
<p>I guess ... but rustc only supports being built with the version of std in-tree</p>



<a name="208911164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911164">(Sep 03 2020 at 01:48)</a>:</h4>
<p>you can't take beta libstd and use that for nightly rustc</p>



<a name="208911171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911171">(Sep 03 2020 at 01:48)</a>:</h4>
<p>they're <em>mutally</em> dependant</p>



<a name="208911186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911186">(Sep 03 2020 at 01:49)</a>:</h4>
<p>is it a literal cycle, or just several trips around the bootstrapping loop</p>



<a name="208911199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911199">(Sep 03 2020 at 01:49)</a>:</h4>
<p><a href="https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html">https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html</a></p>



<a name="208911210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911210">(Sep 03 2020 at 01:49)</a>:</h4>
<p>i.e. rustc can byte for byte reproduce itself in the final stage</p>



<a name="208911260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911260">(Sep 03 2020 at 01:50)</a>:</h4>
<p>yes, if you run stage2 on itself, stage3 should be identical</p>



<a name="208911431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911431">(Sep 03 2020 at 01:53)</a>:</h4>
<p>Aside: Is there a reasonable <a href="https://bootstrappable.org/">bootstrappable build</a> path for rust? That is, to get the latest rust from scratch + source files by a means shorter than replaying every single rust version since the dawn of time</p>



<a name="208911501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911501">(Sep 03 2020 at 01:54)</a>:</h4>
<p>Second compiler not written in Rust, such as mrustc.</p>



<a name="208911508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911508">(Sep 03 2020 at 01:54)</a>:</h4>
<p><a href="https://github.com/dtolnay/bootstrap">https://github.com/dtolnay/bootstrap</a></p>



<a name="208911511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911511">(Sep 03 2020 at 01:54)</a>:</h4>
<p>does it actually work?</p>



<a name="208911513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911513">(Sep 03 2020 at 01:54)</a>:</h4>
<p>sure</p>



<a name="208911516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911516">(Sep 03 2020 at 01:54)</a>:</h4>
<p>but it takes about 100 GB of disk and several days <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="208911543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911543">(Sep 03 2020 at 01:55)</a>:</h4>
<p>oh is dtolnay's project literally just replaying every version?</p>



<a name="208911551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911551">(Sep 03 2020 at 01:55)</a>:</h4>
<p>starting at about 1.31 I think</p>



<a name="208911563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911563">(Sep 03 2020 at 01:56)</a>:</h4>
<p>rustc only supports compiling with rustc (version - 1), so you have to take the slow path</p>



<a name="208911670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911670">(Sep 03 2020 at 01:57)</a>:</h4>
<p>how come the versions break so fast?</p>



<a name="208911727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911727">(Sep 03 2020 at 01:58)</a>:</h4>
<p>rustc does a lot of dogfooding</p>



<a name="208911732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911732">(Sep 03 2020 at 01:58)</a>:</h4>
<p>so a new feature gets implemented and then gets used almost as quickly</p>



<a name="208911786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911786">(Sep 03 2020 at 01:59)</a>:</h4>
<p>e.g. <a href="https://github.com/rust-lang/rust/pull/71220">https://github.com/rust-lang/rust/pull/71220</a></p>



<a name="208911911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911911">(Sep 03 2020 at 02:01)</a>:</h4>
<p>I wonder how bad it would be to keep a rustc that takes much larger bootstrapping jumps, say once per edition</p>



<a name="208911929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911929">(Sep 03 2020 at 02:01)</a>:</h4>
<p>I mean, even without dogfooding it would break pretty often</p>



<a name="208911936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208911936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208911936">(Sep 03 2020 at 02:01)</a>:</h4>
<p>e.g. whenever you add a new lang item</p>



<a name="208952396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208952396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208952396">(Sep 03 2020 at 11:27)</a>:</h4>
<p>The current compiler cannot be built by significantly older toolchains, but for some time ranges it wouldn't be too hard to backport a small set of changes to be able to build the compiler with.</p>
<p>But personally I don't see why you would want to, it wouldn't take that long to bootstrap since 1.0 even; I can build a stage 2 compiler in maybe 15 minutes or so locally - that means 47 versions, modulo changing system deps over the last 5 years, could be built in only ~12 hours. So it's not days of time</p>



<a name="208965888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208965888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208965888">(Sep 03 2020 at 13:25)</a>:</h4>
<blockquote>
<p>I can build a stage 2 compiler in maybe 15 minutes or so locally</p>
</blockquote>
<p>That makes you the odd man out ;) It would take me at <em>least</em> half an hour even with a cached LLVM</p>



<a name="208981696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208981696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208981696">(Sep 03 2020 at 15:08)</a>:</h4>
<p>I see I missed many things.^^ I mostly agree with what <span class="user-mention" data-user-id="239881">@Josh Triplett</span> said. Let me just add that I have very strong feelings on keeping private fields private. In the realm of safe type systems, there is a dividing line between "type systems that support abstraction" and "type systems that do not". Being able to access private fields puts a language firmly into the "no abstractions" camp. Now, with <code>unsafe</code> Rust things become muddy, but I would still be <em>extremely</em> worried about the ecosystem consequences of seemingly "encouraging" abstraction-breaking unsafe code by letting it access private fields. The entire Rust ecosystem rests on the power of abstracting unsafe code behind a safe API. The more we weaken that principle, the weaker Rust's safety story becomes.</p>
<p>So, some kind of opt-in by the "invaded" library is a must, IMO. And if we accept that premise, then macro-based solutions are already possible -- a library can expose unsafe functions that provide accesses to all fields.</p>



<a name="208984219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208984219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208984219">(Sep 03 2020 at 15:24)</a>:</h4>
<p>I don't really see a distinction between unsafe code and privacy invading code. They both fulfill similar roles - the programmer has additional proof obligations in return for access to more features. In fact <code>unsafe</code> itself is sort of like privacy invasion of the compiler intrinsics; it has a safe front end that you can use but if you need to work across that barrier then the previously designed proofs don't apply to you so you have an additional obligation</p>



<a name="208984550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208984550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208984550">(Sep 03 2020 at 15:26)</a>:</h4>
<p>Of course the abstraction theorem still holds in the presence of privacy invading code, because the privacy invading code is exempt from the thorem (it is lumped in with the abstraction)</p>



<a name="208984622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208984622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208984622">(Sep 03 2020 at 15:27)</a>:</h4>
<p>Unsafe code is exactly as much a threat to the abstraction theorem as privacy invasion</p>



<a name="208984769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208984769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208984769">(Sep 03 2020 at 15:28)</a>:</h4>
<blockquote>
<p>a library can expose unsafe functions that provide accesses to all fields.</p>
</blockquote>
<p>What if it didn't?</p>



<a name="208985565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208985565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208985565">(Sep 03 2020 at 15:33)</a>:</h4>
<p>Then the library is free to add or remove fields or change invariants on private fields, such that a library update would make your unsafe code misbehave in horrible ways.</p>



<a name="208985900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208985900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208985900">(Sep 03 2020 at 15:36)</a>:</h4>
<blockquote>
<p>Being able to access private fields puts a language firmly into the "no abstractions" camp. </p>
</blockquote>
<p>Actually, I'm not sure I buy this argument either, intuitive though it sounds at first. Suppose we're going for full correctness, and we've associated some logical proposition to the type invariant that is being protected by the API (for example, in a <code>Mutex</code> implementation we might have <code>Mutex&lt;T&gt;</code> representing <code>Lock(J)</code> and <code>MutexGuard&lt;'a, T&gt;</code> representing <code>J</code> where <code>J</code> is the property of the locked object we wish to preserve). In this case, "a safe API" means that we have theorems saying that the API operations preserve this balance between <code>Lock(J)</code> and <code>J</code> so as long as you only use the provided operations the invariant <code>J</code> is preserved one way or another. But, as the RustBelt paper points out, this kind of inductive invariant is brittle to alternative mechanisms that manage to preserve the invariant anyway without going through the API. What really matters is the invariant, not the API. The API is just an easy way to satisfy the conditions for the theorem</p>



<a name="208986231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208986231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208986231">(Sep 03 2020 at 15:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/208985565">said</a>:</p>
<blockquote>
<p>Then the library is free to add or remove fields or change invariants on private fields, such that a library update would make your unsafe code misbehave in horrible ways.</p>
</blockquote>
<p>As I mentioned earlier, when you do this you are tied to the particular version. The cargo file should make it sufficiently obvious that this is happening that one would not expect a semver compatible library update to work out of the box, just as a semver-incompatible update may well break your code today</p>



<a name="208986418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208986418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208986418">(Sep 03 2020 at 15:39)</a>:</h4>
<p>The library is free to make changes, but the downstream "friend" crate is not free to upgrade</p>



<a name="208986615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208986615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208986615">(Sep 03 2020 at 15:40)</a>:</h4>
<p>Using <code>=x.y.z</code> dependencies is horrible for downstream users, as two dependencies pinning two different semver compatible versions of a library will cause an error, as the semver match means that Cargo wants to use a single version.</p>



<a name="208986712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208986712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208986712">(Sep 03 2020 at 15:41)</a>:</h4>
<p>all good reasons to avoid this feature in a public crate</p>



<a name="208986872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208986872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208986872">(Sep 03 2020 at 15:42)</a>:</h4>
<p>I'm not saying this is a recommended course of action by any stretch. I just want it to be possible, because the currently available alternatives are much worse and more likely to cause subtle memory bugs</p>



<a name="208987038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208987038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208987038">(Sep 03 2020 at 15:43)</a>:</h4>
<p>just because something is unsafe doesn't mean we should make it impossible to get right</p>



<a name="208987620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208987620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208987620">(Sep 03 2020 at 15:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/208987038">said</a>:</p>
<blockquote>
<p>just because something is unsafe doesn't mean we should make it impossible to get right</p>
</blockquote>
<p>I don't think anyone disagrees with that in principle <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="208988472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208988472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208988472">(Sep 03 2020 at 15:52)</a>:</h4>
<p>right now, working with repr(Rust) layouts is impossible to get right because the spec promises next to nothing and the compiler's layout decisions are not available to unsafe code</p>



<a name="208988629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208988629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208988629">(Sep 03 2020 at 15:54)</a>:</h4>
<p>A lot of people focus on the issues with improving the first point but I would rather see progress on the second</p>



<a name="208988913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208988913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208988913">(Sep 03 2020 at 15:55)</a>:</h4>
<p>layout decisions are available insofar as you can, well, query the type layout indirectly, right? Like, you can get a pointer to a field and see what offset that's at</p>



<a name="208988971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208988971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208988971">(Sep 03 2020 at 15:55)</a>:</h4>
<p>not to a private field, sure, but that seems orthogonal</p>



<a name="208989059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208989059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208989059">(Sep 03 2020 at 15:56)</a>:</h4>
<p>Can you do that at compile time?</p>



<a name="208989388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208989388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208989388">(Sep 03 2020 at 15:58)</a>:</h4>
<p><a href="https://github.com/Gilnaa/memoffset#usage-in-constants">https://github.com/Gilnaa/memoffset#usage-in-constants</a></p>



<a name="208991500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208991500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208991500">(Sep 03 2020 at 16:11)</a>:</h4>
<p>Fair enough. I suppose with enough macro magic you can get that to tell you the exact layout, although only for structs that are currently being defined or where you otherwise have an exhaustive list of struct fields, which means <code>derive</code> macros but not reflection on type expressions.</p>



<a name="208991975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208991975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208991975">(Sep 03 2020 at 16:14)</a>:</h4>
<p>I think one of the simplifying premises of Rust is that if you type code into a file, you get to do whatever you want to that code, notionally. But if you don't change the code in a file, then code changed in another file, can't break some aspects of how that file worked, at least not easily. This, for example, makes code review possible, because I don't have to worry about the behavior of the code in file x changing while reviewing code in file y.</p>



<a name="208992446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208992446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208992446">(Sep 03 2020 at 16:18)</a>:</h4>
<p>All of your privacy problems are solved by copying file x into x_prime and changing x_prime. I prefer this solution because it's tedious and noticeable in a code review, etc.</p>



<a name="208992508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208992508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208992508">(Sep 03 2020 at 16:18)</a>:</h4>
<p>I want to reiterate that privacy invasion is just like unsafe code here</p>



<a name="208992531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208992531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208992531">(Sep 03 2020 at 16:19)</a>:</h4>
<p>you have to think globally about unsafe code</p>



<a name="208992618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208992618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208992618">(Sep 03 2020 at 16:19)</a>:</h4>
<p>there's the old "tootsie-pop" model for unsafe code, roughly at the module boundary</p>



<a name="208992712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208992712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208992712">(Sep 03 2020 at 16:20)</a>:</h4>
<p>and that continues to hold here</p>



<a name="208992786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208992786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208992786">(Sep 03 2020 at 16:20)</a>:</h4>
<p>no, privacy invasion makes it a cross-crate concern</p>



<a name="208992898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208992898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208992898">(Sep 03 2020 at 16:21)</a>:</h4>
<p>crate A is verified correct wrt all of A's code and nothing more. crate B that is a friend of A is verified with respect to the code of A and the interface of C (which it does not invade), and is verified correct wrt its own module boundary</p>



<a name="208992931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208992931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208992931">(Sep 03 2020 at 16:21)</a>:</h4>
<p>I'm not actually interested in the theory of privacy invasion being equivalent to other unsafe code. The thing I'm interested in is whether privacy invasion is a tool that has a useful cost benefit analysis in practice, as used by humans.</p>



<a name="208992958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208992958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208992958">(Sep 03 2020 at 16:21)</a>:</h4>
<p>And unfortunately, I suspect that the answer is, no.</p>



<a name="208992973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208992973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208992973">(Sep 03 2020 at 16:22)</a>:</h4>
<p>Its main usefulness is in panic patches</p>



<a name="208993075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208993075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208993075">(Sep 03 2020 at 16:22)</a>:</h4>
<p>Local dependencies solve that.</p>



<a name="208993085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208993085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208993085">(Sep 03 2020 at 16:22)</a>:</h4>
<p>Just fine.</p>



<a name="208993119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208993119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208993119">(Sep 03 2020 at 16:22)</a>:</h4>
<p>where making a copy of large swaths of the dependencies in order to patch one function is not an option</p>



<a name="208993332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208993332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208993332">(Sep 03 2020 at 16:24)</a>:</h4>
<p>I'm not even sure what the upper bound on the amount of copying to be done is. Do you really find that to be a viable strategy?</p>



<a name="208993495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208993495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208993495">(Sep 03 2020 at 16:24)</a>:</h4>
<p>The prospect of setting up my own mini <a href="http://crates.io">crates.io</a> on my computer is quite daunting and I don't know a good reference for how to do it</p>



<a name="208993527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208993527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208993527">(Sep 03 2020 at 16:24)</a>:</h4>
<p>I'm honestly not sure how invading privacy even helps with patching bugs in dependencies. Accessing their fields doesn't change the code the functions in the library run.</p>



<a name="208993609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208993609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208993609">(Sep 03 2020 at 16:25)</a>:</h4>
<p>well I'm thinking here to add a new function that needs access to internals</p>



<a name="208993712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208993712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208993712">(Sep 03 2020 at 16:25)</a>:</h4>
<p>or expose a private function that should have just been unsafe public</p>



<a name="208993898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208993898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208993898">(Sep 03 2020 at 16:27)</a>:</h4>
<p>extension methods of course could find lots of use for accessing internals</p>



<a name="208994028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994028">(Sep 03 2020 at 16:27)</a>:</h4>
<p>But that's not fixing a bug, that's you wanting control that the library author didn't give you.</p>



<a name="208994096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994096">(Sep 03 2020 at 16:28)</a>:</h4>
<p>Those aren't equivalent things.</p>



<a name="208994206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994206">(Sep 03 2020 at 16:28)</a>:</h4>
<p>no, they are separate applications</p>



<a name="208994240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994240">(Sep 03 2020 at 16:28)</a>:</h4>
<p>I'm really glad that Rust's privacy is what it is. The alternative is Ruby's monkeypatching.</p>



<a name="208994299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994299">(Sep 03 2020 at 16:29)</a>:</h4>
<p>Monkeypatching is problematic for performance reasons</p>



<a name="208994308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994308">(Sep 03 2020 at 16:29)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/208993495">said</a>:</p>
<blockquote>
<p>The prospect of setting up my own mini <a href="http://crates.io">crates.io</a> on my computer is quite daunting and I don't know a good reference for how to do it</p>
</blockquote>
<p>There's no need to do this AIUI, you can patch a dependency with a local copy at the final crate level and have it take effect for all dependent crates provided the versions hold.</p>



<a name="208994313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994313">(Sep 03 2020 at 16:29)</a>:</h4>
<p>Which seems to be what you're advocating and I don't like that direction.</p>



<a name="208994361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994361">(Sep 03 2020 at 16:29)</a>:</h4>
<p>(Which is another reason why pinning dependencies to a fixed version is a bad idea)</p>



<a name="208994444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994444">(Sep 03 2020 at 16:30)</a>:</h4>
<p>It's problematic because the behavior of a library changes without an obvious change to the library.</p>



<a name="208994503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994503">(Sep 03 2020 at 16:30)</a>:</h4>
<p>Is there no amount of klaxons that are sufficient to make it obvious?</p>



<a name="208994599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994599">(Sep 03 2020 at 16:31)</a>:</h4>
<p>I didn't say it had to be silent</p>



<a name="208994696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994696">(Sep 03 2020 at 16:32)</a>:</h4>
<p>All of the klaxons I want would involve typing characters into files in that library.</p>



<a name="208994778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994778">(Sep 03 2020 at 16:32)</a>:</h4>
<p>And if you can do that, then well... you can just copy it and you don't need them anyways.</p>



<a name="208994790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994790">(Sep 03 2020 at 16:32)</a>:</h4>
<p>What if the code of the target library is on a network drive that you have no access to?</p>



<a name="208994808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994808">(Sep 03 2020 at 16:32)</a>:</h4>
<p>these situations exist</p>



<a name="208994828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994828">(Sep 03 2020 at 16:32)</a>:</h4>
<p>Great, I can't have a dependency I have no access to.</p>



<a name="208994877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994877">(Sep 03 2020 at 16:33)</a>:</h4>
<p>So, I can't run it, so no problem.</p>



<a name="208994892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994892">(Sep 03 2020 at 16:33)</a>:</h4>
<p>no write access</p>



<a name="208994946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208994946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208994946">(Sep 03 2020 at 16:33)</a>:</h4>
<p>Read access allows copying.</p>



<a name="208995006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995006">(Sep 03 2020 at 16:34)</a>:</h4>
<p>this is what I meant by "power imbalance" earlier</p>



<a name="208995031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995031">(Sep 03 2020 at 16:34)</a>:</h4>
<p>You can use <code>[patch.crates-io]</code> and <code>[replace]</code>.</p>



<a name="208995068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995068">(Sep 03 2020 at 16:34)</a>:</h4>
<p>what are these things?</p>



<a name="208995101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995101">(Sep 03 2020 at 16:34)</a>:</h4>
<p>They allow you to override crates.</p>



<a name="208995131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995131">(Sep 03 2020 at 16:35)</a>:</h4>
<p>And this is what I meant by "I like that it's tedious" earlier. It's easy to see that it's happening and most importantly, it doesn't change the behavior of an existing library.</p>



<a name="208995252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995252">(Sep 03 2020 at 16:35)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> <a href="https://doc.rust-lang.org/nightly/cargo/reference/overriding-dependencies.html">https://doc.rust-lang.org/nightly/cargo/reference/overriding-dependencies.html</a></p>



<a name="208995270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995270">(Sep 03 2020 at 16:36)</a>:</h4>
<p>Aha, that does address a lot of the problems</p>



<a name="208995351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995351">(Sep 03 2020 at 16:36)</a>:</h4>
<p>so you don't have to make a mini <a href="http://crates.io">crates.io</a>, just copy one crate</p>



<a name="208995376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995376">(Sep 03 2020 at 16:36)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">[patch.crates-io]</span>
<span class="n">cranelift-codegen</span> <span class="o">=</span> <span class="p">{</span> <span class="n">path</span> <span class="o">=</span> <span class="s">&quot;./cranelift-codegen&quot;</span> <span class="p">}</span>
</code></pre></div>


<p>Then everyone dependency that uses <code>cranelift-codegen</code> in a specific version will use <code>./cranelift-codegen</code> instead of the <a href="http://crates.io">crates.io</a> version.</p>



<a name="208995416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995416">(Sep 03 2020 at 16:36)</a>:</h4>
<p>Yeah, that's what we've been pointing out the entire time. :)</p>



<a name="208995552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995552">(Sep 03 2020 at 16:37)</a>:</h4>
<p>you still have to manage distribution this way though</p>



<a name="208995620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995620">(Sep 03 2020 at 16:38)</a>:</h4>
<p>can this go in your crate?</p>



<a name="208995672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995672">(Sep 03 2020 at 16:38)</a>:</h4>
<p>you cannot distribute on <a href="http://crates.io">crates.io</a> with this, but that should basically never be necessary as you've said</p>



<a name="208995714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995714">(Sep 03 2020 at 16:39)</a>:</h4>
<p>So you would put this elsewhere in the repo, and use a relative path?</p>



<a name="208995725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995725">(Sep 03 2020 at 16:39)</a>:</h4>
<p>you can build binary artifacts and deploy them to your servers to fix a zero day though, for example</p>



<a name="208995742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995742">(Sep 03 2020 at 16:39)</a>:</h4>
<p>sure, or in a github repository</p>



<a name="208995756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995756">(Sep 03 2020 at 16:39)</a>:</h4>
<p>(it supports overriding with any "type" of dependency)</p>



<a name="208995776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995776">(Sep 03 2020 at 16:39)</a>:</h4>
<p>aha, gotcha</p>



<a name="208995795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995795">(Sep 03 2020 at 16:39)</a>:</h4>
<p>Put another way, it's a <a href="http://crates.io">crates.io</a> restriction that you can't have relative path dependencies not a Rust or Cargo one.</p>



<a name="208995887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995887">(Sep 03 2020 at 16:40)</a>:</h4>
<p>can you have github deps?</p>



<a name="208995906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995906">(Sep 03 2020 at 16:40)</a>:</h4>
<p>On <a href="http://crates.io">crates.io</a>?</p>



<a name="208995914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995914">(Sep 03 2020 at 16:40)</a>:</h4>
<p>yeah</p>



<a name="208995935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995935">(Sep 03 2020 at 16:40)</a>:</h4>
<p>I would guess not</p>



<a name="208995953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995953">(Sep 03 2020 at 16:40)</a>:</h4>
<p>I don't believe so because then you could have crates on <a href="http://crates.io">crates.io</a> that are broken.</p>



<a name="208995970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208995970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208995970">(Sep 03 2020 at 16:41)</a>:</h4>
<p>That's the reason for the policy.</p>



<a name="208996045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208996045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208996045">(Sep 03 2020 at 16:41)</a>:</h4>
<p>are there crates on <a href="http://crates.io">crates.io</a> that are forks of other crates? I don't think I've seen that</p>



<a name="208996067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208996067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208996067">(Sep 03 2020 at 16:41)</a>:</h4>
<p>There's no rule against it</p>



<a name="208996150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208996150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208996150">(Sep 03 2020 at 16:42)</a>:</h4>
<p>you can publish anything to <a href="http://crates.io">crates.io</a> (obviously, should comply with licensing etc)</p>



<a name="208996491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208996491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208996491">(Sep 03 2020 at 16:44)</a>:</h4>
<p>I'm just a little surprised that there aren't more fork popularity wars on <a href="http://crates.io">crates.io</a>, or maybe I just haven't noticed</p>



<a name="208996864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208996864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208996864">(Sep 03 2020 at 16:47)</a>:</h4>
<p>I don't really know :) I guess it seems like there <em>could</em> be but most people who want to fork rather than contribute upstream usually start their own thing rather than fork</p>



<a name="208997057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208997057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208997057">(Sep 03 2020 at 16:49)</a>:</h4>
<p>So it sounds like this pretty much solves the "I need to patch a dependency" use case from up thread. Was that the main reason you wanted detailed layout information?</p>



<a name="208997326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208997326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208997326">(Sep 03 2020 at 16:51)</a>:</h4>
<p>As <span class="user-mention" data-user-id="116122">@simulacrum</span> pointed out, the issues are somewhat orthogonal, but the combination of features seem to work well enough</p>



<a name="208997697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208997697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208997697">(Sep 03 2020 at 16:53)</a>:</h4>
<p>It would not be enough for e.g. autogenerating a schema that describes all type layouts in the program for external consumption</p>



<a name="208997830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208997830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208997830">(Sep 03 2020 at 16:54)</a>:</h4>
<p>things like this are where you really want a proper layout query API</p>



<a name="208997980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208997980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208997980">(Sep 03 2020 at 16:55)</a>:</h4>
<p>You would probably have enough for a serde-like interface to zero-copy serialization though</p>



<a name="208998088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998088">(Sep 03 2020 at 16:56)</a>:</h4>
<p>Such a schema will break as new layout optimizations are added. For example niche-filling in the past.</p>



<a name="208998132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998132">(Sep 03 2020 at 16:56)</a>:</h4>
<p>the idea is that a proper layout API would literally say "I have a niche here"</p>



<a name="208998155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998155">(Sep 03 2020 at 16:57)</a>:</h4>
<p>and the library can do what it wants with that</p>



<a name="208998188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998188">(Sep 03 2020 at 16:57)</a>:</h4>
<p>-Zprint-type-sizes and similar will basically provide that</p>



<a name="208998203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998203">(Sep 03 2020 at 16:57)</a>:</h4>
<p>but it's external, rather than a "rust language API"</p>



<a name="208998256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998256">(Sep 03 2020 at 16:57)</a>:</h4>
<p>I think for that to be correct repr(Rust) needs to at least be deterministic</p>



<a name="208998355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998355">(Sep 03 2020 at 16:58)</a>:</h4>
<p>Lets imagine we were having this conversation just before the niche-filling optimization was implemented. Now consider what would have happened if the layout API was introduced. Now suddenly we couldn't implement niche-filling anymore, as that would be a breaking change.</p>



<a name="208998754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998754">(Sep 03 2020 at 17:01)</a>:</h4>
<p>You could plan for it if the layout API previously had a function "has a niche" that always returns false, but it's true that the layout API would not be forward compatible if you didn't even have the concept before</p>



<a name="208998920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998920">(Sep 03 2020 at 17:02)</a>:</h4>
<p>It need not be deterministic so long as it is consistent <em>within the compiled binary</em></p>



<a name="208998937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998937">(Sep 03 2020 at 17:02)</a>:</h4>
<p>i.e., we do not reorder your fields at runtime</p>



<a name="208998959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998959">(Sep 03 2020 at 17:03)</a>:</h4>
<p>which I would suspect we can basically RFC fairly easily today</p>



<a name="208998983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208998983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208998983">(Sep 03 2020 at 17:03)</a>:</h4>
<p>(and is just technically infeasible for current compilation model)</p>



<a name="208999230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999230">(Sep 03 2020 at 17:05)</a>:</h4>
<p>Would <code>-Zprint-type-sizes</code> work with a two stage build? That is, the types are used to construct some data that should be accessible to the program, so you have to run it once and then get the types and then run it again with the type info</p>



<a name="208999376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999376">(Sep 03 2020 at 17:06)</a>:</h4>
<p>I would guess not, since that can obviously change the types in general, but it would be nice if there was some set of circumstances in which you could ensure that such a scheme would work</p>



<a name="208999425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999425">(Sep 03 2020 at 17:06)</a>:</h4>
<p>I mean, you can check and if it did great</p>



<a name="208999436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999436">(Sep 03 2020 at 17:06)</a>:</h4>
<p>it basically will</p>



<a name="208999448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999448">(Sep 03 2020 at 17:06)</a>:</h4>
<p>how can you check?</p>



<a name="208999456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999456">(Sep 03 2020 at 17:06)</a>:</h4>
<p>...run twice and compare?</p>



<a name="208999524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999524">(Sep 03 2020 at 17:07)</a>:</h4>
<p>That was the other half of my original complaint, that unsafe code can't assert the invariants it relies on</p>



<a name="208999688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999688">(Sep 03 2020 at 17:08)</a>:</h4>
<p>Not all of them, but certainly some</p>



<a name="208999724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999724">(Sep 03 2020 at 17:08)</a>:</h4>
<p>and generally speaking I would say that permitting asserting invariants is an active area of interest</p>



<a name="208999725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999725">(Sep 03 2020 at 17:08)</a>:</h4>
<p>In the code I might want to say <code>static_assert_eq!(layout&lt;T&gt;(), Layout { size: 8, fields: [Field {name: "foo", offset: 4}] })</code> for example</p>



<a name="208999797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999797">(Sep 03 2020 at 17:09)</a>:</h4>
<p>I can see why you'd want that. Reflection APIs seem generally useful :)</p>



<a name="208999799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999799">(Sep 03 2020 at 17:09)</a>:</h4>
<p>(just making up some syntax)</p>



<a name="208999808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/208999808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#208999808">(Sep 03 2020 at 17:09)</a>:</h4>
<p>but are hard to get right</p>



<a name="209000047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209000047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209000047">(Sep 03 2020 at 17:11)</a>:</h4>
<p>Using <code>offset_of</code> and <code>size_of</code> and code generation I think you can assert the broad strokes of a data type at compile time</p>



<a name="209000130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209000130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209000130">(Sep 03 2020 at 17:11)</a>:</h4>
<p>yes, broadly so</p>



<a name="209000221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209000221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209000221">(Sep 03 2020 at 17:12)</a>:</h4>
<p>so you could do a two stage build and at least do basic sanity checking of your info on the second run</p>



<a name="209000739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209000739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209000739">(Sep 03 2020 at 17:15)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/208998754">said</a>:</p>
<blockquote>
<p>You could plan for it if the layout API previously had a function "has a niche" that always returns false, but it's true that the layout API would not be forward compatible if you didn't even have the concept before</p>
</blockquote>
<p>Which I think is the fundamental problem. There may be additional concepts we may wish to exploit for layout but unless we can enumerate all of them now we either accept the API could change in the future which I believe diminishes the usefulness of it or we accept that we cannot do those optimizations which feels like a bad tradeoff to me.</p>



<a name="209000877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209000877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209000877">(Sep 03 2020 at 17:16)</a>:</h4>
<p>It does seem like an unstable API by nature</p>



<a name="209000880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209000880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209000880">(Sep 03 2020 at 17:16)</a>:</h4>
<p>We have had conversations about things like <code>repr(linear)</code> or similar before though</p>



<a name="209000917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209000917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209000917">(Sep 03 2020 at 17:17)</a>:</h4>
<p>and unstable reflection APIs that permit getting at layout details  for structs seem not infeasible, with the perpetual unstableness hat</p>



<a name="209000943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209000943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209000943">(Sep 03 2020 at 17:17)</a>:</h4>
<p>It could be selectively stabilized if and when people agree on stabilizing certain aspects of repr(Rust)</p>



<a name="209001229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209001229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209001229">(Sep 03 2020 at 17:19)</a>:</h4>
<p>like <code>has_a_niche</code> could be stabilized when people agree that having a niche is a property types can possess (that depends only on the type and not the phase of the moon)</p>



<a name="209001587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209001587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209001587">(Sep 03 2020 at 17:21)</a>:</h4>
<p>To some extent, sure</p>



<a name="209001710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209001710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209001710">(Sep 03 2020 at 17:22)</a>:</h4>
<p>Like, if you wanted to propose this, the MCP route on the lang-team repo is the way to go, I think, though probably we need a project group and it feels like it's a major project and outside current priorities for lang team</p>



<a name="209001746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209001746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209001746">(Sep 03 2020 at 17:22)</a>:</h4>
<p>and anything like my <code>layout&lt;T&gt;()</code> would be perpetually unstable because it purports to exhaustively enumerate all layout properties</p>



<a name="209001771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209001771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209001771">(Sep 03 2020 at 17:22)</a>:</h4>
<p>especially because most of it can sort of be done, e.g., bindgen asserts type layouts are the same with offsetof! and similar</p>



<a name="209004485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209004485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209004485">(Sep 03 2020 at 17:43)</a>:</h4>
<p>I should point out also that there is a good reason to stage things here: you can get into circularities like</p>
<div class="codehilite"><pre><span></span><code><span class="k">struct</span> <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">arr</span>: <span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">layout</span>::<span class="o">&lt;</span><span class="n">Foo</span><span class="o">&gt;</span><span class="p">().</span><span class="n">get_field</span><span class="p">(</span><span class="s">&quot;arr&quot;</span><span class="p">).</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="209028419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209028419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209028419">(Sep 03 2020 at 20:55)</a>:</h4>
<p>Well, that's just another instance of existing const generic problems like <code>struct Foo([u8; size_of::&lt;Foo&gt;() + 1]);</code>.  Cycle detection always needs to handle that.</p>



<a name="209073100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073100">(Sep 04 2020 at 09:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/208984622">said</a>:</p>
<blockquote>
<p>Unsafe code is exactly as much a threat to the abstraction theorem as privacy invasion</p>
</blockquote>
<p>No, that's not true at all. unsafe code <a href="https://plv.mpi-sws.org/rustbelt/popl18/">can be formally proven to be safe to use</a> and <em>that proof relies on abstraction</em> and thus privacy. In other words, unsafe code is only correct ("sound") if the ecosystem respects privacy. The only reason that <code>unsafe</code> doesn't break the Rust ecosystem is that we have working privacy! That's why I have such strong feelings on privacy.</p>
<p>Yes, unsafe code <em>can</em> break privacy, we cannot avoid that. But it usually doesn't, and that is key for being able to write reliable software in Rust.</p>



<a name="209073431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073431">(Sep 04 2020 at 09:42)</a>:</h4>
<p>Further unsafe code can break those boundaries. This does not invalidate your theorem</p>



<a name="209073438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073438">(Sep 04 2020 at 09:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/208992531">said</a>:</p>
<blockquote>
<p>you have to think globally about unsafe code</p>
</blockquote>
<p>If that were true, it would be near impossible to write correct unsafe code. But lucky enough, through the power of abstraction, it is possible to reason locally about unsafe code. To give a concrete example, that ability to do local reasoning is <em>the only thing</em> that sets apart Rust's <code>Vec</code> from C++'s <code>std::vector</code>!</p>



<a name="209073478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073478">(Sep 04 2020 at 09:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/209073431">said</a>:</p>
<blockquote>
<p>Further unsafe code can break those boundaries. This does not invalidate your theorem</p>
</blockquote>
<p>unsound unsafe code can break everything. Sound unsafe code does not break abstraction boundaries.</p>



<a name="209073498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073498">(Sep 04 2020 at 09:43)</a>:</h4>
<p>Unsafe code has proof obligations</p>



<a name="209073511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073511">(Sep 04 2020 at 09:43)</a>:</h4>
<p>privacy breaking code also has proof obligations</p>



<a name="209073559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073559">(Sep 04 2020 at 09:44)</a>:</h4>
<p>with privacy, proof obligations can be discharged locally</p>



<a name="209073566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073566">(Sep 04 2020 at 09:44)</a>:</h4>
<p>yes</p>



<a name="209073570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073570">(Sep 04 2020 at 09:44)</a>:</h4>
<p>without privacy, they become a whole-program concern, impossible to manage</p>



<a name="209073621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073621">(Sep 04 2020 at 09:44)</a>:</h4>
<p>Rust's safety story simply doesn't work without privacy.</p>



<a name="209073686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073686">(Sep 04 2020 at 09:45)</a>:</h4>
<p>module A can be proven correct wrt module A's boundaries. Module B which invades module A is an extension of the theorem for module A, it might involve adapting the original proof, but it can still be proven with respect to module B's boundaries</p>



<a name="209073695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073695">(Sep 04 2020 at 09:45)</a>:</h4>
<p>and anything that is not invaded can still be abstract</p>



<a name="209073716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073716">(Sep 04 2020 at 09:46)</a>:</h4>
<p>so it's not nearly as dire as you propose</p>



<a name="209073759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073759">(Sep 04 2020 at 09:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/208985900">said</a>:</p>
<blockquote>
<blockquote>
<p>Being able to access private fields puts a language firmly into the "no abstractions" camp. </p>
</blockquote>
<p>Actually, I'm not sure I buy this argument either, intuitive though it sounds at first. Suppose we're going for full correctness, and we've associated some logical proposition to the type invariant that is being protected by the API (for example, in a <code>Mutex</code> implementation we might have <code>Mutex&lt;T&gt;</code> representing <code>Lock(J)</code> and <code>MutexGuard&lt;'a, T&gt;</code> representing <code>J</code> where <code>J</code> is the property of the locked object we wish to preserve). In this case, "a safe API" means that we have theorems saying that the API operations preserve this balance between <code>Lock(J)</code> and <code>J</code> so as long as you only use the provided operations the invariant <code>J</code> is preserved one way or another. But, as the RustBelt paper points out, this kind of inductive invariant is brittle to alternative mechanisms that manage to preserve the invariant anyway without going through the API. What really matters is the invariant, not the API. The API is just an easy way to satisfy the conditions for the theorem</p>
</blockquote>
<p>I do not understand your argument here. But the API is what matters because it is the thing that actually manifests the abstraction barrier in code. The invariant is just a mathematical fiction that we put up to justify correctness of the API.</p>



<a name="209073806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073806">(Sep 04 2020 at 09:46)</a>:</h4>
<p>you just entangled the correctness proof of A and B, so they become one proof</p>



<a name="209073809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073809">(Sep 04 2020 at 09:46)</a>:</h4>
<p>The barrier is not the goal, correct code is the goal</p>



<a name="209073830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073830">(Sep 04 2020 at 09:47)</a>:</h4>
<p>yes, they become one proof</p>



<a name="209073850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073850">(Sep 04 2020 at 09:47)</a>:</h4>
<p>they become like one super-module</p>



<a name="209073873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073873">(Sep 04 2020 at 09:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/209073809">said</a>:</p>
<blockquote>
<p>The barrier is not the goal, correct code is the goal</p>
</blockquote>
<p>the only way we know to make code correct is to beak apart the correctness argument into small pieces and estabish abstarction barriers in between them</p>



<a name="209073895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073895">(Sep 04 2020 at 09:47)</a>:</h4>
<p>the reason C/C++ fail is that they dont have proper abstraction barriers</p>



<a name="209073929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073929">(Sep 04 2020 at 09:47)</a>:</h4>
<p>This is still something you can selectively apply</p>



<a name="209073937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073937">(Sep 04 2020 at 09:48)</a>:</h4>
<p>proof complexity grows <em>much more than linear</em> with module size. it's probably more like exponential.</p>



<a name="209073987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073987">(Sep 04 2020 at 09:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/209073929">said</a>:</p>
<blockquote>
<p>This is still something you can selectively apply</p>
</blockquote>
<p>sure. ask module A owner to expose unsafe methods that let module B do these things.</p>



<a name="209073998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209073998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209073998">(Sep 04 2020 at 09:48)</a>:</h4>
<p>rather than one mega proof you have 10 separate proofs and one double-wide proof for a tricky bit</p>



<a name="209074001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074001">(Sep 04 2020 at 09:48)</a>:</h4>
<p>we <em>already have</em> mechanism to selectively do this, with mutual consent of all modules involved</p>



<a name="209074040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074040">(Sep 04 2020 at 09:48)</a>:</h4>
<p>without consent, this is a recipe for disaster</p>



<a name="209074092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074092">(Sep 04 2020 at 09:49)</a>:</h4>
<p>What is the privacy story when there are unsafe accessors?</p>



<a name="209074104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074104">(Sep 04 2020 at 09:49)</a>:</h4>
<p>Or the correctness story, I mean</p>



<a name="209074183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074183">(Sep 04 2020 at 09:50)</a>:</h4>
<p>unsafe accessors have a proof obligation on their caller, carefully documented by module A, saying something like "you need to make sure my library invariant is upheld". so, they make the library invariant part of the API, and subject to stability promises.</p>



<a name="209074216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074216">(Sep 04 2020 at 09:50)</a>:</h4>
<p>Right. The <em>exact same thing</em> applies with privacy invasion</p>



<a name="209074223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074223">(Sep 04 2020 at 09:50)</a>:</h4>
<p>no</p>



<a name="209074230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074230">(Sep 04 2020 at 09:50)</a>:</h4>
<p>you still have those same proof obligations to uphold</p>



<a name="209074244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074244">(Sep 04 2020 at 09:50)</a>:</h4>
<p>you missed the part where I said "the library invariant part of the API, and subject to stability promises"</p>



<a name="209074250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074250">(Sep 04 2020 at 09:50)</a>:</h4>
<p>that is currently not the case</p>



<a name="209074263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074263">(Sep 04 2020 at 09:51)</a>:</h4>
<p>you need the invaded library to opt in to that</p>



<a name="209074278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074278">(Sep 04 2020 at 09:51)</a>:</h4>
<p>just like it needs to <code>impl Copy for Type</code></p>



<a name="209074309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074309">(Sep 04 2020 at 09:51)</a>:</h4>
<p>I don't follow</p>



<a name="209074372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074372">(Sep 04 2020 at 09:52)</a>:</h4>
<p>I'm afraid I have to get back to work, sorry</p>



<a name="209074400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074400">(Sep 04 2020 at 09:52)</a>:</h4>
<p>the point is that invasion <em>without consent by whom you are invading</em> is a disaster for the ecosystem</p>



<a name="209074440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074440">(Sep 04 2020 at 09:53)</a>:</h4>
<p>I am not sure if you are still arguing for "general invasion into all the things", if yes, then -- see all of the above for why that is a problem</p>



<a name="209074449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074449">(Sep 04 2020 at 09:53)</a>:</h4>
<p>If we could somehow better document the invariants, this could be done in a correctness preserving way</p>



<a name="209074458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074458">(Sep 04 2020 at 09:53)</a>:</h4>
<p>if no, then -- we dont need a new language feature for that</p>



<a name="209074492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074492">(Sep 04 2020 at 09:53)</a>:</h4>
<p>even if we could, not all lib authors will want to commit to their invariants being <em>stable</em>. a key feature of abstraction is that you ca change implementation details and nobody notices.</p>



<a name="209074571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074571">(Sep 04 2020 at 09:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/209074449">said</a>:</p>
<blockquote>
<p>If we could somehow better document the invariants, this could be done in a correctness preserving way</p>
</blockquote>
<p>if by "document" you mean "have the compiler check and enforce them", sure... at that point we are turning Rust into a theorem prover though. Which it did not want to be, that's why it has <code>unsafe</code>.</p>



<a name="209074578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074578">(Sep 04 2020 at 09:54)</a>:</h4>
<p>I agree that library invariants are not likely to be stable, which is why privacy invasion usually means that you can't safely make semver-compatible upgrades</p>



<a name="209074596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074596">(Sep 04 2020 at 09:55)</a>:</h4>
<p>I would love it if rust were a theorem prover :)</p>



<a name="209074624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074624">(Sep 04 2020 at 09:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/209074596">said</a>:</p>
<blockquote>
<p>I would love it if rust were a theorem prover :)</p>
</blockquote>
<p>so would I. but then nobody would be able to use it.^^</p>



<a name="209074661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074661">(Sep 04 2020 at 09:55)</a>:</h4>
<p>maybe in a decade or 3 we have the tech to make theorem proving accessible to people without a CS degree. but right now, we do not, so Rust made a great call here.</p>



<a name="209074790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074790">(Sep 04 2020 at 09:57)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/209074578">said</a>:</p>
<blockquote>
<p>I agree that library invariants are not likely to be stable, which is why privacy invasion usually means that you can't safely make semver-compatible upgrades</p>
</blockquote>
<p>given that much of Rust is based on the concept that you <em>can</em> always make semver-compatible updates ("stability without stagnation"), this alone is already a dealbreaker</p>



<a name="209074844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074844">(Sep 04 2020 at 09:58)</a>:</h4>
<p>Fair enough. My view on privacy is that if you have correctness, privacy is useless cruft. <code>unsafe</code> already satisfies all of the needs of guarding theorem statements without privacy</p>



<a name="209074933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074933">(Sep 04 2020 at 09:58)</a>:</h4>
<p>it just looks like OO throwback to me</p>



<a name="209074997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209074997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209074997">(Sep 04 2020 at 10:00)</a>:</h4>
<p>What about a rust compiler flag that turns off all privacy guards? That would be enough for panic patches</p>



<a name="209075071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209075071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209075071">(Sep 04 2020 at 10:00)</a>:</h4>
<p>It would also permanently exile you from <a href="http://crates.io">crates.io</a>, so there are no dependency problems</p>



<a name="209075280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209075280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209075280">(Sep 04 2020 at 10:03)</a>:</h4>
<p>Ah, actually you need more than <code>unsafe</code> to replace privacy, you also need <code>unstable</code> markers for internals</p>



<a name="209075403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209075403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209075403">(Sep 04 2020 at 10:04)</a>:</h4>
<p>but if something is both unsafe and unstable to access, it seems you are pretty well covered when it comes to changing it and possibly breaking someone's code</p>



<a name="209075610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209075610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209075610">(Sep 04 2020 at 10:07)</a>:</h4>
<p>Anyway, I've made enough ruckus for now. Thanks to everyone who was patient enough to respond, I promise I won't publish any crates with horrible hacks such as I've described</p>



<a name="209081623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209081623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209081623">(Sep 04 2020 at 11:22)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/querying.20type.20niche.20status/near/209074933">said</a>:</p>
<blockquote>
<p>it just looks like OO throwback to me</p>
</blockquote>
<p>I'm going to be the first to join you in saying that the benefits of OO are vastly overstated... but IMO Rust copied some of the best parts of OO, which are interfaces (<code>trait</code>) and modularity through privacy. It left behind things that just don't work well most of the time, like inheritance. Looks like we disagree on which parts of OO are worth keeping and which are not. ;)</p>
<p>If you want to hear more about the importance of abstraction (and, by extension, privacy) based on principled formal foundations, I can recommend <a href="https://www.youtube.com/watch?v=8Xyk_dGcAwk">this talk</a> by my PhD advisor.</p>
<div class="youtube-video message_inline_image"><a data-id="8Xyk_dGcAwk" href="https://www.youtube.com/watch?v=8Xyk_dGcAwk"><img src="https://i.ytimg.com/vi/8Xyk_dGcAwk/default.jpg"></a></div>



<a name="209083415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209083415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209083415">(Sep 04 2020 at 11:44)</a>:</h4>
<p>In particular I'd argue that reflection (aka invading privacy of others) is one of those things that we should <em>not</em> copy from OO -- something that even Java realized with version 9. ;)</p>



<a name="209085713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209085713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209085713">(Sep 04 2020 at 12:09)</a>:</h4>
<p>The idea of abstraction is a nice one, but it seems to come from the same mythos of functional programming that the computer doesn't matter and we can idealize its behavior away, and that's where I get off the bus. Rust is a great language <em>because</em> it combines the careful attention to computational lowering from C and C++ as well as the attention to program semantics from functional languages. Reflection is the idea that the program we write is observable, it is bits that execute on a real machine; we can look at states of the turing machine that is our code and act on it. All macro code works from this premise. Lisps did this the best, with code = data, but they neglect the compile/run time phase distinction so high performance is off the table.</p>
<p>I want a language that can do all these things. Does that mean I have to write Python that writes C++? Please no.</p>



<a name="209086307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/querying%20type%20niche%20status/near/209086307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/querying.20type.20niche.20status.html#209086307">(Sep 04 2020 at 12:15)</a>:</h4>
<p>(Anyway, these are only my opinions at this point. Just so you know where I'm coming from.)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>